#include <stdlib.h>
#include <string.h>

#include "SendList.hpp"
/**
 * SendList
 **/
SendList::SendList()
{
	this->request=NULL;
	this->next=NULL;
}
SendList::~SendList()
{
	free(this->request);
}
void SendList::add(char* request)
{
	// TODO : lock (vs sendManager) + RequestManager
	/* empty list */
	if(!this->request)
	{
		this->request=(char*)malloc(2048);
		strcpy(this->request,request);
		return;
	}
	/* else */
	{
		SendList* temp=this->next;
		this->next=new SendList();
		this->next->request=(char*)malloc(2048);
		strcpy(this->next->request,request);
		this->next->next=temp;
	}
}

void SendList::clear()
{
	// TODO : Lock
	if(this->next)
	{
		SendList* current=next;
		SendList* next;
		while(current)
		{
			next=current->next;
			delete current;
			current=next;
		}
	}
	free(this->request);
	this->request=NULL;
	this->next=NULL;
}
